package com.Algorithm.HUAWEI.two20220303;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Parameter;
import java.nio.Buffer;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2022/03/18/22:55
 * @Description:
 * @Target:
 */
public class 密码截取 {
    // 先解决---X----型


    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String ss = in.readLine();

        int maxLen = 0;
        int index = 0;
        // 走---x---
        char cc ='a';
        for (int i = 1; i < ss.length()-1; i++) {
            int len = 0;
            // ---xx---
            len = getLen(ss, i-1, i);

            if (len>maxLen){
                maxLen = maxLen>len?maxLen:len;
                index = i;
                cc = ss.charAt(i);
            }

            // ---abxba--
            len = getLen(ss, i-1, i + 1);
            if (len>maxLen){
                maxLen = maxLen>len?maxLen:len;
                index = i;
                cc = ss.charAt(i);
            }
        }


        System.out.print("长度："+maxLen+"   下标："+index+"   值为："+cc);
    }


    static int getLen(String ss,int leftIndex,int rightIndex){
        if (rightIndex==ss.length()||leftIndex==-1){
            return 0;
        }
        int maxLen = ss.charAt(rightIndex)==ss.charAt(leftIndex)?2:0;
        if (rightIndex-leftIndex==1&&ss.charAt(rightIndex)==ss.charAt(leftIndex)){
             maxLen = 2;
        }else if (rightIndex-leftIndex==1&&ss.charAt(rightIndex)!=ss.charAt(leftIndex)){
            maxLen = 1;
            return maxLen;
        }else if (rightIndex-leftIndex==2&&ss.charAt(rightIndex)==ss.charAt(leftIndex)){
            maxLen = 3;
        }else if (rightIndex-leftIndex==2&&ss.charAt(rightIndex)!=ss.charAt(leftIndex)){
            maxLen = 1;
            return maxLen;
        }

        if (leftIndex>0&&rightIndex<ss.length()-1&&ss.charAt(leftIndex-1)==ss.charAt(rightIndex+1)){
            maxLen = maxLen+getLen(ss,leftIndex-1,rightIndex+1);
        }else {
            return maxLen;
        }

        return maxLen;
    }
}
